<?php

namespace app\controllers\api;

use app\component\tencentCloud\sms\TencentCloudSms;
use app\controllers\ApiController;
use app\qo\SmsQo;
use app\services\tencentCloud\sms\TemplateSms;

class SmsController extends ApiController
{
    /**
     * @return array
     */
    public function actionSend(): array
    {
        //大陆
        $phones = ['17630301996'];

        //美国
//        $code = 'US';
//        $phones = ['6788273357'];

        $qo = new SmsQo();
        $qo->code = $code ?? 'CN';
        $qo->phoneNumberSet = $phones;
        $qo->templateId = TemplateSms::VERIFY_CODE_TEMPLATE_ID;
        $qo->templateParamSet = [rand(100000, 999999)];

        $res = \Yii::$app->sms->SendSms($qo);
        return parent::jsonResponse($res);
    }

}